package com.rocket.bedroom.security;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: 周毅
 * @ClassName:
 * @Description: TODO
 * @Date: Create in 14:47 2020/6/14
 * @ModifyBy:
 */
public class RedisCacheManager implements CacheManager
{

    /**
     * @param cacheName 缓存key:authentication，authorization
     * @param <K>
     * @param <V>
     * @return
     * @throws CacheException
     */
    @Override
    public <K, V> Cache<K, V> getCache(String cacheName) throws CacheException
    {
        /**
         * 将shiro缓存形式换成 redis，
         *  1、首先实现ShiroCacheManager缓存管理器，自定义getCache方法
         *  2、自定义实现Cache，将缓存数据换替换为redis数据库
         */
        return new RedisShrioCache<K, V>();
    }
}
